var modifyPassword_page={};

modifyPassword_page.action = {
    initBody:function () {
        modifyPassword_page.action.bindEvent();
    },
    bindEvent:function () {
        $("#saveBtn").click(function () {
            modifyPassword_page.action.modifyPassword();
            return false;
        });
    },
    modifyPassword:function () {
        var oldPassword = $("#oldPassword").val().trim();
        var newPassword = $("#newPassword").val().trim();
        var newPassword2 = $("#newPassword2").val().trim();
        if (oldPassword=='') {
            layer.alert('旧密码不能为空！',{
                icon: 5,
                kin: 'layer-ext-moon'
            });
            return;
        }
        if (newPassword=='' || newPassword.length<6) {
            layer.alert('请输入6位及以上的新密码！',{
                icon: 5,
                kin: 'layer-ext-moon'
            });
            return;
        }
        if (newPassword2=='') {
            layer.alert('确认密码不能为空！',{
                icon: 5,
                kin: 'layer-ext-moon'
            });
            return;
        }
        if (newPassword!=newPassword2) {
            layer.alert('新密码与确认密码不一致！',{
                icon: 5,
                kin: 'layer-ext-moon'
            });
            return;
        }
        layer.confirm('确定要修改密码吗？',{icon: 3, title:'提示'},function(index){
            var onSuccess = function (resultData) {
                if (resultData.success) {
                    layer.msg("修改成功！", {icon: 1});
                } else {
                    layer.msg(resultData.error, {icon: 2});
                }
            };
            var params = {
                oldPassword:oldPassword,
                newPassword:newPassword
            };
            AppComm.ajax.execute({
                'url':AppComm.url.getBaseURL()+'/userManager/ajax/modifyPassword',
                'data':params,
                'success':onSuccess
            });
            layer.close(index);
        }, function(index){
            layer.close(index);
        });
    }
};


AppComm.initFrame(modifyPassword_page);